PRG 1.0 TXT

/*
	Diffuse mapping shader program for Material sample
*/

//-----------------------------------------------------------------------------
// [CONFIG]

include "..\program_include.ocf"

object Program
{
	type		= 0x00020002;	// e_program.DIFFUSE | e_program.CUBEMAP;
	layer_bits	= e_render_layer_bits.ALL;
	
	ubo_data	= array /*UBO*/ {
		{ "inMaterial", e_program_data.MATERIAL }
	}

	textures	= array /*ProgramTexture*/ {
		{ "unDiffuseMap", e_texture.DIFFUSE }
	}
	
	uniforms	= array /*string*/ {
		"transform", "unTransform."
	}
}


//-----------------------------------------------------------------------------
// [VERTEX]

#version 330 core
#pragma optimize(on)

#define ATTR_POSITION	0
#define ATTR_NORMAL		1
#define ATTR_TEXCOORD	2

layout(location = ATTR_POSITION)	in vec3  inPosition;
layout(location = ATTR_NORMAL)		in vec3  inNormal;
layout(location = ATTR_TEXCOORD)	in vec3  inTexcoord;

uniform struct TTransform {
	mat4	MVP;
	mat3	Normal;
} unTransform;


out	TVertexData {
	vec3	vTexcoord;
	vec3	vNormal;
} Output;


void main()
{
	gl_Position		 = unTransform.MVP * vec4(inPosition, 1.0);
	Output.vTexcoord = inTexcoord;
	Output.vNormal	 = inNormal * unTransform.Normal;
}


//-----------------------------------------------------------------------------
// [FRAGMENT]

#version 330 core
#pragma optimize(on)

layout(location = 0, index = 0)	out vec4  outColor;

uniform samplerCube	unDiffuseMap;

layout(std140)
uniform inMaterial {
	vec3	vAmbientColor;
	vec4	vDiffuseColor;
	vec3	vSpecularColor;
	vec3	vEmissionColor;
	float	fShininess;
} unMaterial;


in	TVertexData {
	vec3	vTexcoord;
	vec3	vNormal;
} Input;


void main()
{
	outColor = texture( unDiffuseMap, Input.vTexcoord ) * unMaterial.vDiffuseColor;
	outColor.rgb += unMaterial.vAmbientColor;
	outColor.rgb += unMaterial.vEmissionColor;
}

// [END]
